Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[META 388] Proposal for collecting Azure App Service cloud metadata #365

Merged
merged 9 commits into from
Mar 11, 2021

Conversation

russcam
Copy link
Contributor

@russcam russcam commented Nov 11, 2020

This commit updates the cloud metadata spec to propose collecting Azure App Service metadata.

Azure App Services are a very popular PaaS offering on Azure. In contrast to Azure VMs, App Services do not have access to the internal metadata endpoint in order to retrieve metadata about the app instance. Instead, much of the metadata that is relevant to the purposes of APM are available in environment variables.

The environment variables of interest are documented here.

This commit updates the cloud metadata
spec to propose collecting Azure App Service
metadata.

Azure App Services are a very popular PaaS offering
on Azure. In contrast to Azure VMs, App Services do
not have access to the internal metadata endpoint
in order to retrieve metadata about the app instance.
Instead, much of the metadata that is relevant to the
purposes of APM are available in environment variables.

The environment variables of interest are documented
here.
@russcam russcam requested review from a team as code owners November 11, 2020 04:03
@apmmachine
Copy link

apmmachine commented Nov 11, 2020

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #365 updated

  • Start Time: 2021-03-09T02:45:30.589+0000

  • Duration: 5 min 54 sec

  • Commit: dd3b003

Trends 🧪

Image of Build Times

Copy link
Contributor

@mikker mikker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

How do we determine what PaaS-platforms to include checks for? I feel a little bit like as soon as we start adding some, we can never stop adding new ones as they pop up 😅

@mikker
Copy link
Contributor

mikker commented Nov 11, 2020

We could let it be up to the individual agents what platforms to support, so the PaaS' are optional.

Azure's is probably way more used for .NET than for Ruby, for example, where Heroku might be the exact opposite situation.

Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! What method should be used to identify that you're running within Azure App Service? Presence of valid WEBSITE_* environment variables?

We could let it be up to the individual agents what platforms to support, so the PaaS' are optional.

++

| `instance.id` | `WEBSITE_INSTANCE_ID` |
| `instance.name` | `WEBSITE_SITE_NAME` |
| `project.name` | `WEBSITE_RESOURCE_GROUP` |
| `provider` | azure |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there value in capturing the cloud product, perhaps cloud.product: azure-app-service as well? It appears we'd need a new cloud ecs field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ I think there could be. cloud fields look to be very much intended for VMs e.g. availability_zone, machine_type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With elastic/ecs#1204 we will have an ECS field for this as of next release - cloud.service.name. elastic/apm-server#4625 is tracking addition to the intake for this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for somehow capturing the fact that this set of metadata is being captured in an azure-app-services environment in order to make it distinct from data collected via the instance endpoints. I was thinking similar thoughts when I investigated this for node.js recently specifically around a theoretical problem of a user looking at two sets of azure data and wondering why different fields are collected from each.

##### Azure App Services

Azure App Services are a PaaS offering within Azure which doe not
have access to the internal metadata endpoint. Metadata about
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What @axw said in an earlier comment:

What method should be used to identify that you're running within Azure App Service? Presence of valid WEBSITE_* environment variables?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The presence of WEBSITE_* environment variables and the format of WEBSITE_OWNER_NAME should be sufficient.

@russcam
Copy link
Contributor Author

russcam commented Nov 23, 2020

We could let it be up to the individual agents what platforms to support, so the PaaS' are optional.

I think this is a reasonable approach. Perhaps I should mark Azure App Services as optional in the spec?

@russcam
Copy link
Contributor Author

russcam commented Nov 25, 2020

Marked Azure App Service Metadata as optional.

I think the only thing left is to determine a timeline for implementation. @alex-fedotyev / @graphaelli, thoughts on where this might slot in? Happy to write a prototype implementation for the .NET agent too.

@russcam
Copy link
Contributor Author

russcam commented Dec 8, 2020

I've opened elastic/apm-agent-dotnet#1083 as an example implementation

@graphaelli
Copy link
Member

@alex-fedotyev and I discussed this. He's going to investigate adoption across agents and help set priority on this.

@alex-fedotyev
Copy link

@russcam - did you check if our current logic for collecting cloud metadata would not work for Azure App Services?
I am wondering whether it is already detecting cloud provider and region + availability zone details.

Also instance ID would be interesting to leverage in setting up service.node.name, how does the agent assign the node names today for AppServices?

Did you check if WEBSITE_ env variables are present in the AppServices for Linux? I remember leveraging them on Windows, but not sure about Linux.

Azure Functions also set WEBSITE_ environment variables, technically they are part of the App Service infrastructure.
But functions also set additional env var FUNCTIONS_EXTENSION_VERSION. Would we want to check that?

From my experience, I recall .NET/Java/Node.js and PHP being well adopted on Azure AppService platform. This looks to me as an improvement worth of doing across at least those language agents.

| `project.name` | `WEBSITE_RESOURCE_GROUP` |
| `provider` | azure |
| `region` | last part of `WEBSITE_OWNER_NAME`, split by `-`, trim end `"webspace"` |

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@russcam datapoint: When I deployed a node application via azure app services my region looked like

    "WEBSITE_RESOURCE_GROUP": "appsvc_linux_centralus",

i.e. the WEBSITE_OWNER_NAME was delimited with underscores characters (_) and not the hyphen/dash. You can see this here (will be slow in coming up if the app's gone idle)

What do you think about spec-ing this as splitting by - OR _ -- or perhaps even "splitting by non-alpha-numeric-characters"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the additional data point. Looks like there may be some cross-language and cross-platform differences in environment variable values. For example, the node app value is

"WEBSITE_OWNER_NAME": "7657426d-c4c3-44ac-88a2-3b2cd59e6dba+appsvc_linux_centralus-CentralUSwebspace-Linux"

The extracted region should be CentralUS, though the value includes a -Linux suffix which wasn't present on the .NET app service.

I think what might be good for me to do before updating the PR is to deploy some other language app services to see if there is more variation in values. It might be a simple case of updating the WEBSITE_OWNER_NAME rule to substring from 0 up to start of webspace, then split by - and take the last value.

@russcam
Copy link
Contributor Author

russcam commented Feb 19, 2021

I've added some gherkin specs to indicate what success and failure scenarios 9768039. With these specs, agents can generate the steps for a test

@basepi
Copy link
Contributor

basepi commented Mar 8, 2021

What's the status on this spec? Theoretically it's slated for 7.12 which is in two weeks. Can we wrap it up and get it merged so agents can implement? Alternatively we could push it to 7.13, but we should make a decision on that.

/cc @AlexanderWert

russcam and others added 2 commits March 9, 2021 12:22
This commit updates the Azure App Service Metadata spec
to indicate that webspace(.*) should be trimmed from the last
part of `WEBSITE_OWNER_NAME` split by '-', in order to get
the region.
@russcam
Copy link
Contributor Author

russcam commented Mar 9, 2021

@basepi good question :)

I believe with the addition of gherkin specs with scenarios to demonstrate expected outcomes, this is good to merge- I added a link to the specs and clarified how region is obtained, based on @astorm's input in #365 (comment). I deployed empty Azure App Services for node and python and couldn't replicate the WEBSITE_OWNER_NAME format seen, but it's a small logical change to accommodate in the spec.

@basepi
Copy link
Contributor

basepi commented Mar 9, 2021

In that case, let's make this the last call for input on this spec. @russcam is going to merge it in two days (March 11) unless there is more feedback.

@russcam
Copy link
Contributor Author

russcam commented Mar 11, 2021

Thanks for everyone's input, merging this in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.